﻿Imports SchemaCodeGen
Imports Framework

Partial Class pages_contents_Default : Inherits CPage

#Region "Querystring"
	Public ReadOnly Property TemplateId As Integer
		Get
			Return CWeb.RequestInt("templateId")
		End Get
	End Property
	Public ReadOnly Property SetId As Integer
		Get
			Return CWeb.RequestInt("setId")
		End Get
	End Property
	Public ReadOnly Property Search As String
		Get
			Return CWeb.RequestStr("search")
		End Get
	End Property
#End Region

#Region "Data"

	Public ReadOnly Property Contents() As CContentList
		Get
			Return CContent.Cache.Search(TemplateId, SetId, txtSearch.Text) 'Paging done in usercontrol
		End Get
	End Property
#End Region


#Region "Page Events"
	Protected Overrides Sub PageInit()
		ddTemplate.DataSource = SchemaCodeGen.CTemplate.Cache
		ddTemplate.DataBind()
		CDropdown.BlankItem(ddTemplate, "-- Any Template --")
		CDropdown.SetValue(ddTemplate, TemplateId)

		ddSet.DataSource = CTemplateSet.Cache
		ddSet.DataBind()
		CDropdown.BlankItem(ddSet, "-- Any Pattern --")
		CDropdown.SetValue(ddSet, SetId)

		ctrl.Display(Contents)
	End Sub
#End Region

	Protected Sub btnSearch_Click(sender As Object, e As System.EventArgs)
		Response.Redirect(CSitemap.Contents(CDropdown.GetInt(ddTemplate), CDropdown.GetInt(ddSet), txtSearch.Text))
	End Sub
End Class
